package com.qupai.controller.user;

import com.qupai.constant.StatusConstant;
import com.qupai.entity.PtPrize;
import com.qupai.result.Result;
import com.qupai.service.PtPrizesService;
import com.qupai.vo.PtPrizesVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController("userPtPrizesController")
@RequestMapping("/user/ptprizes")
@Slf4j
@Tag(name = "普通-C端-奖品浏览接口")
@RequiredArgsConstructor
public class PtPrizesController {

    private final PtPrizesService prizesService;

    @GetMapping("/list")
    @Operation(summary = "根据学院分类id查询奖品")
    public Result<List<PtPrizesVO>> list(Long collegesId){
        PtPrize prizes=new PtPrize();
        prizes.setCollegesId(collegesId);
        prizes.setStatus(StatusConstant.ENABLE);

        List<PtPrizesVO> prizesVOList=prizesService.selectPrizesList(prizes);
        return Result.success(prizesVOList);
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据id查询奖品")
    public Result<PtPrizesVO>getById (@PathVariable Long id){
        log.info("根据id查询奖品:{}",id);
        PtPrizesVO prizesVO=prizesService.getById(id);
        return Result.success(prizesVO);
    }

}
